package com.yyf.blogapi.controller;


import com.yyf.blogapi.service.ICommentService;
import com.yyf.blogapi.vo.CommentParam;
import com.yyf.blogapi.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yyf
 * @since 2021-08-16
 */
@RestController
@RequestMapping("/comments")
public class CommentController {

    @Resource
    private ICommentService commentService;

    @GetMapping("/article/{id}")
    public Result comments(@PathVariable("id") Long articleId) {
        return Result.success(commentService.getCommentsByArticleId(articleId));
    }

    @PostMapping("/create/change")
    public Result createComment(@RequestBody CommentParam commentParam){
        return Result.success(commentService.saveComment(commentParam));
    }
}
